<template>
    <div class="fix" v-if="this.$store.state.oneitem">
       <div class="fix_one">
            <el-menu  class="el-menu-demo" id="topchild" mode="horizontal" :default-active="activeIndex">
                    <el-menu-item index="1">处理中心</el-menu-item>
                    <el-menu-item index="2" @click.native="close">关闭</el-menu-item>
            </el-menu>
            <el-form ref="form" :model="form" label-width="130px" style="margin-top:30px;">
                <el-form-item label="姓名（必填）">
                    <el-input v-model="form.name" style="width:360px;"></el-input>
                </el-form-item>
                <el-form-item label="电话（必填）">
                    <el-input v-model="form.mobile" style="width:360px;"></el-input>
                </el-form-item>
                <el-form-item label="密码（必填）">
                    <el-input v-model="form.password" style="width:360px;"></el-input>
                </el-form-item>
                <el-form-item label="状态（必填）">
                    <el-select  v-model="form.status" placeholder="请选择状态">
                        <el-option v-for="(item, key) in stats" :value="key" :key="key" :label="item"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click.native="fixClick">修改</el-button>
                </el-form-item>
            </el-form>
       </div>
    </div>
</template>
<script> 
import { Base64 } from 'js-base64';
    export default {
        name: 'fix',
        data() {    
            return {
                activeIndex: '1',
                form: {
                    name: '',
                    mobile: '',
                    password: '',
                    status:'',
                },
                stats: { "1": '正常', "-1": '禁用' },
            }
        },
        created:function(){
            if(this.$store.state.oneitem){
                console.log(this.$store.state.oneitem)
                this.form.name = this.$store.state.oneitem.name;
                this.form.mobile = this.$store.state.oneitem.mobile;
                this.form.password = this.$store.state.oneitem.password;
                this.form.status = this.stats[this.$store.state.oneitem.status];
                }
        },
        components: {

        },
        methods: {
            close(){
                this.$store.state.fixShow = false;
            },
            fixClick(){
                var a = this.form.status==='正常'?'1':'-1';
                console.log(a);
                console.log(this.form.name);
                console.log(this.form.mobile);
                console.log(this.form.password);
                console.log(this.form.status);
                var paramesdata = {
                    name: this.form.name,
                    mobile: this.form.mobile,
                    status:a,
                    password:this.form.password,
                    id:this.$store.state.oneitem.id,
                }
                this.$store.dispatch('allData', { method: "post", url: this.$store.state.baseurl + 'admin/admin/edit', selected: 'editData', paramesdata: paramesdata,code:'eitcode' });
                if(this.$store.state.eitcode=='200'){
                    alert('修改成功');
                    parent.location.reload()
                }
            }
        },
        filters:{
            staespli(val){
                return val===1?'正常':'禁用'
            }
        },
    }
</script>

<style scoped>
    .fix{width: 100%;height: 100%;background:rgba(0, 0, 0, 0.6);position: fixed;top: 0px;}
    .fix_one{width: 40%;height: 70%;position: absolute;left: 25%;top: 15%;background-color: white;}
    .fix .fix_one .el-form .el-form-item__label{color: #606266;}
</style>